using System;
using System.Collections.Generic;
using System.Text;

namespace XnaDevRu.Bullet
{
	public class BroadphaseProxy
	{
		//Usually the client CollisionObject or Rigidbody class
		private object _clientObject;
		private CollisionFilterGroups _collisionFilterGroup;
		private CollisionFilterGroups _collisionFilterMask;

		public BroadphaseProxy() { }

		public BroadphaseProxy(object userData, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask)
		{
			_clientObject = userData;
			_collisionFilterGroup = collisionFilterGroup;
			_collisionFilterMask = collisionFilterMask;
		}

		public object ClientData { get { return _clientObject; } set { _clientObject = value; } }
		public CollisionFilterGroups CollisionFilterGroup { get { return _collisionFilterGroup; } set { _collisionFilterGroup = value; } }
		public CollisionFilterGroups CollisionFilterMask { get { return _collisionFilterMask; } set { _collisionFilterMask = value; } }

		public static bool IsPolyhedral(BroadphaseNativeTypes proxyType)
		{
			return (proxyType < BroadphaseNativeTypes.ImplicitConvexShapes);
		}

		public static bool IsConvex(BroadphaseNativeTypes proxyType)
		{
			return (proxyType < BroadphaseNativeTypes.ConcaveShapesStart);
		}

		public static bool IsConcave(BroadphaseNativeTypes proxyType)
		{
			return ((proxyType > BroadphaseNativeTypes.ConcaveShapesStart) &&
				(proxyType < BroadphaseNativeTypes.ConcaveShapesEnd));
		}
		public static bool IsCompound(BroadphaseNativeTypes proxyType)
		{
			return (proxyType == BroadphaseNativeTypes.Compound);
		}
		public static bool IsInfinite(BroadphaseNativeTypes proxyType)
		{
			return (proxyType == BroadphaseNativeTypes.StaticPlane);
		}

		//optional filtering to cull potential collisions
		public enum CollisionFilterGroups
		{
			Default = 1,
			Static = 2,
			Kinematic = 4,
			Debris = 8,
			Sensor = 16,
			All = Default | Static | Kinematic | Debris | Sensor,
		}
	}
}
